import { request,requestOther } from '@/utils/request';
import { TenpayH5Result, TenpayJsapiModel, TenpayTradeQueryModel, AlipayTradeQueryModel } from '@/api/model/payModel';

const Api = {
  AlipayJsapi: '/alipay/wappay',
  AlipayTradeQuery: '/alipay/trade/query',
  TenpayJsapi: 'https://pay.rscode.cn/api/tenpay/jsapi',
  TenpayH5: '/tenpay/h5',
  TenpayTradeQuery: '/tenpay/trade/query',
};

// 支付宝预支付信息
export const alipayPrepayInfo = (params: any) => {
  return request.post(
    {
      url: Api.AlipayJsapi,
      data: params,
    },
    {
      isTransformResponse: false,
    },
  );
};
// 微信支付预支付信息
export const tenpayPrepayInfo = (params: any) => {
  return requestOther.post<TenpayJsapiModel>({
    url: Api.TenpayJsapi,
    data: params,
  });
};
export const tenpayH5PrepayInfo = (params: any) => {
  return request.post<TenpayH5Result>({
    url: Api.TenpayH5,
    data: params,
  });
};
// 查询订单结果
export const alipayQueryTrade = (params: any) => {
  return request.get<AlipayTradeQueryModel>({
    url: `${Api.AlipayTradeQuery}?orderNo=${params.orderNo}`,
  });
};
export const tenpayQueryTrade = (params: any) => {
  return request.get<TenpayTradeQueryModel>({
    url: `${Api.TenpayTradeQuery}?orderNo=${params.orderNo}`,
  });
};
